import ktor.KtorLocationsDataSource
import models.Location

class LocationsRepositoryImpl(
    private val dataSource: KtorLocationsDataSource
) : LocationsRepository {
    override suspend fun locations(): Result<List<Location>> {
        return dataSource.getLocations().checkNullAndGet()
    }

    override suspend fun createLocation(name: String): Result<Int> {
        return dataSource.createLocation(name).checkNullAndGet()
    }

    override suspend fun deleteLocation(id: Int): Result<Boolean> {
        return dataSource.deleteLocation(id).checkNull()
    }
}